<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Curl转Python</title>
    <link rel="icon" href="{{ url_for('static', filename='ico/favicon_curl.png') }}">

    <link rel="stylesheet" href="{{ url_for('static', filename='css/curl_input.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/curl_convert.css') }}">
    <link rel="stylesheet" href="{{ url_for('static', filename='css/alert_msg.css') }}">

    <!-- 使用 highlight.js -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/styles/atom-one-dark.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/highlight.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.8.0/languages/python.min.js"></script>
    <!-- 自定义 js -->
    <script type="module" src="{{ url_for('static', filename='js/common.js') }}"></script>
    <script type="module" src="{{ url_for('static', filename='js/commom_req.js') }}"></script>
    <script type="module" src="{{ url_for('static', filename='js/curl_convert.js') }}"></script>
    <script>
        <!-- 美化 :-->
        document.addEventListener('DOMContentLoaded', (event) => {hljs.highlightAll();});
    </script>

</head>
<body>

<!-- Python 脚本展示区 : -->
<h2>生成的 Python 脚本:</h2>
<pre id="pythonCode"><code class="language-python" contenteditable="true" id="pyCode">{{ python_code }}</code></pre>

<div class="button-container">
    <div class="btn-group">
        <form method="post">
            <input type="hidden" id="curl_command" name="curl_command" value="{{ curl_command }}">
            <!--
            执行脚本按钮是执行 curl 命令, 是 Windows 下执行的, 现在部署 Linux 了, 即去掉该按钮 : )
            其实也可以将脚本中的 python 改为 python3 尝试兼容, 只是有了执行代码其实可以去掉执行 curl
            <input type="submit" name="execute" value="执行脚本">
            -->
        </form>
        <button class="copy-btn" onclick="execute_py('/execute_py')">执行代码</button>
        <button class="copy-btn" onclick="copyToClipboard('pythonCode', 'Python代码')">复制代码</button>
        <a href="/" style="text-decoration: none;">
            <button>返回</button>
        </a>
    </div>
</div>

<!-- 执行结果显示区 : -->
<h2>执行结果:</h2>
<pre id="result">
    <code>
        {% if result %}
            {{ result }}
        {% else %}
        {% endif %}
    </code>
</pre>

<!-- 复制执行结果: -->
<div class="button-container">
    <button class="copy-btn" onclick="copyToClipboard('result', '执行结果')">复制执行结果</button>
</div>

<!-- 自定义通知, 右上角的通知区 -->
<div id="custom-alert" class="custom-alert"></div>

</body>
</html>
